package juc.CAS.原子类;

public class AtomicTest {
    private static volatile int sum = 0;

    public static void main(String[] args) throws InterruptedException {
        for (int j = 0; j < 10; j++) {
            new Thread(() -> {
                for (int i = 0; i < 1000; i++) {
                    sum++;
                }
            }).start();
        }
        while (Thread.activeCount() > 1) {
            Thread.yield();
        }

        System.out.println(sum);
    }
}